%%Graphs for the NBER presentation
clc
close all
clear all

%%%%%%%%%%%%%%%%%%%%Baseline%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

load Baseline;
load OnlyTrade;
load OnlyIPR;
load DomesticIPR;
load Anticipated;
load Anticipatedoptimal;
load Gradual;
load Myopic;
load Chinadeviates;


%%Welfare analysis

%%%%United States
figure
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off



%%%%China
figure
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off




%%%%%%%%%%%%%%%%%%%%Baseline, only trade, only IPR%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C1counterf_onlytrade(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_onlyIPR=plot([zeros(1,10) C1counterf_onlyIPR(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '-.','color', 'k');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only trade','Only IPR','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off



%%%%China
figure
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C3counterf_onlytrade(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_onlyIPR=plot([zeros(1,10) C3counterf_onlyIPR(1:50).*100])
set(graph_onlyIPR,'LineWidth',2, 'LineStyle', '-.','color', 'k');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only trade','Only IPR','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off




%%%%%%%%%%%%%%%%%%%%Baseline vs myopic%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_myopic=plot([zeros(1,10) C1counterf_myopic(1:50).*100])
set(graph_myopic,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Myopic','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off



%%%%China
figure
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_myopic=plot([zeros(1,10) C3counterf_myopic(1:50).*100])
set(graph_myopic,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Myopic','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off



%%%%%%%%%%%%%%%%%%%%Baseline vs domestic IPR%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_domesticIPR=plot([zeros(1,10) C1counterf_domesticIPR(1:50).*100])
set(graph_domesticIPR,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Domestic IPR','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off



%%%%China
figure
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_myopic=plot([zeros(1,10) C3counterf_domesticIPR(1:50).*100])
set(graph_myopic,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Domestic IPR','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off





%%%%%%%%%%%%%%%%%%%%Baseline, only trade, China deviates%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%Welfare analysis

%%%%United States
figure
hold on 
graph_baseline=plot([zeros(1,10) C1counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C1counterf_onlytrade(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_Chinadeviates=plot([zeros(1,10) C1counterf_Chinadeviates(1:50).*100])
set(graph_Chinadeviates,'LineWidth',2, 'LineStyle', '-.','color', 'k');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only trade','Chinadeviates','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} United States'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off



%%%%China
figure
hold on 
graph_baseline=plot([zeros(1,10) C3counterf(1:50).*100])
set(graph_baseline,'LineWidth',2, 'LineStyle', '-','color', 'b');
graph_onlytrade=plot([zeros(1,10) C3counterf_onlytrade(1:50).*100])
set(graph_onlytrade,'LineWidth',2, 'LineStyle', '--','color', 'r');
graph_Chinadeviates=plot([zeros(1,10) C3counterf_Chinadeviates(1:50).*100])
set(graph_Chinadeviates,'LineWidth',2, 'LineStyle', '-.','color', 'k');
graph_zeros=plot(zeros(60,1))
set(graph_zeros,'LineWidth',2, 'LineStyle', '--','color', 'k');
legend('Baseline','Only trade','Chinadeviates','Initial BGP')
%legend('Baseline','Only IPR','Initial BGP')

title(['\fontsize{16} China'])
ylabel(['\fontsize{14} log consumption (rel. initial BGP trend)'])
xticks([1 6 11 16 21 26 31 36 41 46 51 56 61])
xticklabels({'-10','-5','0','5','10','15','20','25','30','35','40','45','50','55', '60'})

hold off
